package com.dg.cuckoo.admin.action.integratedQuery;

import com.dg.cuckoo.admin.dto.basicInformation.projectInformation.BasicProjectDto;
import com.dg.cuckoo.admin.service.ProjectInfoService;
import com.dg.cuckoo.core.BaseController;
import com.dg.cuckoo.core.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

/**
 * 综合查询-项目信息
 */
@RestController
@RequestMapping("/integratedQuery/projectInfo")
public class ProjectInfo extends BaseController {

    @Autowired
    private ProjectInfoService service;

    /**
     * 查询
     * @return
     */
    @PostMapping("query")
    public JsonResult<List<BasicProjectDto>> query(String oneLabel,String twoLabel,String unit,String year,String mainName){
        List<BasicProjectDto> data = service.query(oneLabel, twoLabel, unit, year, mainName);
        return new JsonResult<>(OK,data);
    }

    /**
     * 点击一级标签显示数据
     */
    @PostMapping("openOneLabel")
    public JsonResult<List<String>> openOneLabel(){
        List<String> data = service.openOneLabel();
        return new JsonResult<>(OK,data);
    }

    /**
     * 点击二级标签显示数据
     */
        @PostMapping("openTwoLabel")
    public JsonResult<List<String>> openTwoLabel(String oneLabel){
        List<String> data = service.openTwoLabel(oneLabel);
        return new JsonResult<>(OK,data);
    }

    /**
     * 根据id显示数据
     */
    @PostMapping("openInfo")
    public JsonResult<BasicProjectDto> openInfo(String id){
        BasicProjectDto data = service.openInfo(id);
        return new JsonResult<>(OK,data);
    }

    /**
     * 导出excel
     */
    @PostMapping("inport")
    public JsonResult<Void> inport(List<BasicProjectDto> list) throws IOException {
        service.inport(list);
        return new JsonResult<>(OK);
    }

}
